package com.xyh.contract;

import feign.MethodMetadata;
import org.springframework.cloud.netflix.feign.support.SpringMvcContract;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

public class MyContract extends SpringMvcContract {
    @Override
    protected void processAnnotationOnMethod(MethodMetadata data, Annotation methodAnnotation, Method method) {
        super.processAnnotationOnMethod(data, methodAnnotation, method);
        if(MyUrl.class.isInstance(methodAnnotation)){
            MyUrl myUrl=method.getAnnotation(MyUrl.class);
            String url=myUrl.url();
            String httpMethod=myUrl.method();
            data.template().append(url);
            data.template().method(httpMethod);
        }
    }
}
